package com.study.shirojwtredis.shiro.provider.impl;

import com.study.shirojwtredis.domain.Account;
import com.study.shirojwtredis.shiro.provider.AccountProvider;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.stereotype.Service;

import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @ClassName AccountProviderImpl
 * @Author One_llx
 * @Date 2019/11/21 0021 下午 7:39
 * @Version 1.0
 */
@Service("accountProvider")
public class AccountProviderImpl implements AccountProvider {

    private static final AtomicLong ato=new AtomicLong(1L);

    @Override
    public Account loadAccount(String account) {
        //去service查询
        Account account1=new Account();
        account1.setAccount(account);
        String salt = UUID.randomUUID().toString();
        String passwd = new Md5Hash(account, salt, 10).toString();
        account1.setSalt(salt);
        account1.setPassd(passwd);
        account1.setaId(ato.getAndIncrement());
        return account1;
    }
}
